<?php
ob_start("ob_gzhandler");

$app_dir = dirname(__FILE__);

set_include_path('.' . PATH_SEPARATOR . "$app_dir/library" . PATH_SEPARATOR . "$app_dir/model/" . PATH_SEPARATOR . get_include_path());

require_once 'Zend/Loader.php';

Zend_Loader::registerAutoload();

/**
 * Setup controller
 */
$request = new Zend_Controller_Request_Http();

$controller = Zend_Controller_Front::getInstance();
$controller->setControllerDirectory("$app_dir/controllers", "default");
$controller->setParam('useDefaultControllerAlways', true);
$controller->throwExceptions(true); // should be turned on in development time

$config = new Zend_Config_Ini("$app_dir/config.ini");
Zend_Registry::set('lc_db', Zend_Db::factory($config->get('database')));


/**
 * Add routes for Layered Content
 */
$router = $controller->getRouter();

// Add route for specific *.entry requests for AtomPub entries
$router->addRoute("layeredEntry", new Zend_Controller_Router_Route_Regex(
	'atom/([^/]+)/(.+)',
	array('action' => 'handle'),
	array(1 => 'controller', 2 => 'key'),
	'atom/%s/%s'
));

// Add route for *.list requests. These are AtomPub collections
$router->addRoute("layeredList", new Zend_Controller_Router_Route_Regex(
	'atom/([^/]+)',
	array('action' => 'handle'),
	array(1 => 'controller'),
	'atom/%s'
));
		



// run!
$controller->dispatch($request);

?>